import re
import time
from itertools import zip_longest

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

# 设置ChromeDriver的路径（根据你的实际路径来设置）
# chromedriver_path = '/path/to/your/chromedriver'

# 初始化浏览器驱动
driver = webdriver.Chrome()

# 打开目标网页
driver.maximize_window()
driver.get('https://login.1688.com/member/signin.htm')
wait=WebDriverWait(driver,5)
# 获取页面HTML内容
content = driver.page_source
account='//*[@id="fm-login-id"]'
password='//*[@id="fm-login-password"]'

print(content)
time.sleep(10)
# 定义您想要滚动到的X和Y坐标
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
time.sleep(2)
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
time.sleep(2)
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
time.sleep(2)
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
time.sleep(2)
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
time.sleep(2)
x_coordinate = 0  # 通常是0，除非您想要水平滚动
y_coordinate = 6000 # 这是垂直滚动的距离，您可以根据需要调整
driver.execute_script("window.scrollTo({}, {});".format(x_coordinate, y_coordinate))
time.sleep(10)
# 获取公司域名
pattern_name=r',"tpCreditUrl":"http://(.*?).1688.com/page/creditdetail.htm"'
get_name=re.findall(pattern_name,content)
print(get_name)
# 关闭浏览器驱动
driver.quit()